home *** CD-ROM | disk | FTP | other *** search
- //Pop-it menu- By Dynamic Drive
- //For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
- //This credit MUST stay intact for use
-
- function showmenu(e,which){
- if (!document.all&&!document.getElementById&&!document.layers)
- return;
-
- clearhidemenu();
-
- menuobj = document.all.popmenu;
- menuobj.thestyle = menuobj.style;
-
- menuobj.innerHTML = which;
-
- menuobj.contentwidth = menuobj.offsetWidth;
- menuobj.contentheight = menuobj.offsetHeight;
- eventX = event.clientX;
- eventY = event.clientY;
-
- //Find out how close the mouse is to the corner of the window
- var rightedge = document.body.clientWidth - eventX;
- var bottomedge = document.body.clientHeight - eventY;
-
- //if the horizontal distance isn't enough to accomodate the width of the context menu
- //if (rightedge<menuobj.contentwidth)
- //move the horizontal position of the menu to the left by it's width
- menuobj.thestyle.left = document.body.scrollLeft+eventX-menuobj.contentwidth - 4;
- //else
- //position the horizontal position of the menu where the mouse was clicked
- //menuobj.thestyle.left = document.body.scrollLeft+eventX;
-
- //same concept with the vertical position
- if (bottomedge < menuobj.contentheight)
- menuobj.thestyle.top = document.body.scrollTop + eventY - menuobj.contentheight;
- else
- menuobj.thestyle.top = document.body.scrollTop + event.clientY;
-
- // force set position
- //menuobj.thestyle.left = 330;
- //menuobj.thestyle.top = 20;
- menuobj.thestyle.visibility="visible"
-
- return false
- }
-
- function hidemenu(){
- if (window.menuobj)
- menuobj.thestyle.visibility = "hidden";
- }
-
- function dynamichide(e){
- if (!menuobj.contains(e.toElement))
- hidemenu();
- }
-
- function delayhidemenu(){
- delayhide = setTimeout("hidemenu()", 500);
- }
-
- function clearhidemenu(){
- if (window.delayhide)
- clearTimeout(delayhide);
- }
-
- function highlightmenu(e,state){
- if (document.all)
- source_el = event.srcElement;
- else if (document.getElementById)
- source_el = e.target;
- if (source_el.className=="menuitems"){
- source_el.id = (state == "on")?"mouseoverstyle":"";
- } else {
- while(source_el.id != "popmenu"){
- source_el = document.getElementById?source_el.parentNode:source_el.parentElement;
- if (source_el.className == "menuitems"){
- source_el.id = (state == "on")?"mouseoverstyle":"";
- }
- }
- }
- }
-
- document.onclick = hidemenu;